package com.starmark.gateway.auth.provider.mapper;



import com.starmark.core.framework.base.SuperMapper;
import com.starmark.gateway.auth.provider.entity.GatewayAuthRor;
import com.starmark.gateway.auth.provider.vo.AuthOrgElementDto;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author starmark
 * @since 2018-04-27
 */
@Mapper
public interface GatewayAuthRorMapper extends SuperMapper<GatewayAuthRor> {

    /**
     * 查找角色下的授权信息
     *
     * @param roleId
     * @return
     */
    @Select("select  org_id,org_name,org_type from gateway_auth_ror where role_id=#{roleId}")
    @ResultMap("OrgElementMap")
    List<AuthOrgElementDto> getRoleOrg(@Param("roleId") String roleId);

    /**
     * 删除角色下的授权信息
     *
     * @param roleId 角色ID
     */
    @Delete("delete  from gateway_auth_ror where role_id=#{roleId}")
    void deleteByRoleId(@Param("roleId") String roleId);


    /**
     * 删除角色下的授权信息
     *
     * @param roleId 角色ID
     */
    @Delete("delete  from sys_auth_ror where role_id=#{roleId} and org_id=#{orgId}")
    void deleteByRoleIdAndOrgId(@Param("roleId") String roleId, @Param("orgId") String orgId);


}